package com.xqb.mq;

import com.alibaba.fastjson2.JSON;
import com.xqb.common.constants.MQConstants;
import com.xqb.modules.domain.po.InsReview;
import com.xqb.modules.service.MsgMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;

/**
 * @Author: JinChen Zhu
 * @CreateTime: 2024-10-29  12:35
 */
@Component
@Slf4j
public class EmailConsumer {
    @Autowired
    private MsgMessageService msgMessageService;

    @RabbitListener(queues = MQConstants.EMAIL_INSTITUTION_QUEUE)
    public void sendInsReviewMsg(String insReviewDtoJson) throws MessagingException {
        InsReview insReview = JSON.parseObject(insReviewDtoJson, InsReview.class);
        log.info("邮件队列消息：{}", insReview);
        msgMessageService.sendInsReviewMsg(insReview);
    }


}
